package cn.scau.server.controller;


import cn.scau.server.dto.ApplicationRecordsDTO;
import cn.scau.server.dto.ProcessReceiveDTO;
import cn.scau.server.dto.SearchRecordsDTO;
import cn.scau.server.pojo.ApplicationItemRecords;
import cn.scau.server.service.ApplicationRecordsService;
import cn.scau.server.vo.ResultVO;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 代码不跑我先跑
 * @since 2025-03-30
 */
@RestController
@RequestMapping("/application-records")
public class ApplicationRecordsController {
    @Resource
    private ApplicationRecordsService applicationRecordsService;

    @ApiOperation("添加申请记录")
    @PostMapping("/add")
    public ResultVO add(@RequestBody ApplicationRecordsDTO applicationRecordsDTO) {
        return applicationRecordsService.addRecord(applicationRecordsDTO);
    }

    @ApiOperation("查看个人申请记录")
    @PostMapping("/getPersonalRecords")
    public ResultVO getPersonalRecords(@RequestBody SearchRecordsDTO searchRecordsDTO) {
        return applicationRecordsService.getPersonalRecords(searchRecordsDTO);
    }

    @ApiOperation("查看个人某条记录")
    @GetMapping("/getPersonSingleRecord")
    public ResultVO getPersonSingleRecord(@RequestParam Integer recordId,@RequestParam String empId) {
        return applicationRecordsService.getPersonalSingleRecords(recordId,empId);
    }

    @ApiOperation("查询领导需要审批的申请")
    @PostMapping("/getLeaderApprovalList")
    public ResultVO getLeaderApprovalList(@RequestBody SearchRecordsDTO searchRecordsDTO) {
        return applicationRecordsService.getLeaderApprovalList(searchRecordsDTO);
    }

    @ApiOperation("员工撤销申请")
    @PutMapping("/revokeApplication")
    public ResultVO revokeApplication(@RequestParam Integer recordId) {
        return applicationRecordsService.revokeApplication(recordId);
    }

    @ApiOperation("领导审批")
    @PutMapping("/leaderApproval")
    public ResultVO leaderApproval(@RequestParam Integer recordId, @RequestParam String empId,
                                   @RequestParam Integer deptId,@RequestParam Boolean pass) throws ParseException {
        return applicationRecordsService.approval(recordId,deptId,empId,pass);
    }
}
